using System;
using System.Collections.Generic;

namespace Com.ContentRendering.Api.DataEngine.Handler.Self
{
    /// <summary/>
    internal class BooleanSelfHandler : AbstractSelfHandler
    {
        /// <summary/>
        internal BooleanSelfHandler(
            ReflectionCache reflectionCache,
            object value)
            : base(
            reflectionCache,
            value) { }

        /// <summary/>
        internal override IEnumerator<object> Parse()
        {
            // if the value a string then handle it ... (remember the string has the enumerable interface)
            if (!typeof(bool).IsInstanceOfType(base._value))
            {
                return base._successor.Parse();
            }

            bool parsedValue = (bool)base._value;

            List<object> parsedValues = new List<object>();

            // is set then add an empty string
            if (parsedValue)
            {
                parsedValues.Add(string.Empty);
            }

            return parsedValues.GetEnumerator();        
        }
    }
}

